package com.jyh.demo.homework;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        System.out.println("请输入源字符串：");
        String srcStr = new Scanner(System.in).next();
        System.out.println("输入要删除的字符串：");
        String delStr = new Scanner(System.in).next();
        //调用replaceAll方法
        String result = srcStr.replaceAll(delStr, "");
        //(源字符串的长度-删除后的字符串长度)/要删除的字符串长度=删除的字符串的次数
        int count=(srcStr.length()-result.length())/delStr.length();
        System.out.println(delStr+"总共出现了："+count+"次");
        System.out.println("删除"+delStr+"后的字符串为："+result);

    }
}
